/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "向量.h"

#include "Px碰撞几何体.h"
#include "../../../S_Physics.h"


struct S_Px物理引擎核心;


struct S_Px平面 : public S_物理体 {
	physx::PxRigidStatic*	m_Plane;
	physx::PxShape*			m_Shape;

	S_Px平面(physx::PxPhysics* phy, S_物理几何体& geom, S_物理材质& 材质, uint32 key=0);
	~S_Px平面();

	void*	f_getBody() { return m_Plane; }

};





struct S_Px刚体 : public S_物理体 {
	
	physx::PxRigidDynamic*	m_刚体;
	physx::PxShape*			m_Shape;



	S_Px刚体(S_Px物理引擎核心* core, S_物理几何体& geom, S_物理材质& 材质, uint32 key=0);
	~S_Px刚体();



	inline void*	f_getBody()		{ return m_刚体; }
	inline void*	f_get关联对象()	{ return m_Shape->userData; }
	inline void		f_冻结(bool no) { m_刚体->setActorFlag(physx::PxActorFlag::eDISABLE_SIMULATION, no); }


	//void f_构建(S_Px物理引擎核心* core, const S_三角Mesh mesh, const vec3& loc, const vec4& rot, const vec3& scale);
	inline void f_绑定关联对象(void* data) { 
		m_刚体->userData = data;
		m_Shape->userData = data; 
	}

	//void f_setLocation(const vec3& loc);
	//void f_setRot(const vec3& loc);
	void f_setLocRot(const vec3& loc, const vec3& r);
	void f_setPos(const vec3& l);
	void f_setRot(const vec3& r);
	void f_setVel(const vec3& l);
	vec3 f_getLocation();

};










struct S_Px控制刚体 : public S_物理体 {

	physx::PxRigidDynamic*	m_刚体;
	physx::PxShape*			m_Shape;



	S_Px控制刚体(S_Px物理引擎核心* core, S_物理几何体& geom, S_物理材质& 材质, uint32 key = 0);
	~S_Px控制刚体();



	inline void* f_getBody() { return dynamic_cast<physx::PxRigidActor*>(m_刚体); }
	inline void* f_get关联对象() { return m_刚体->userData; }

	inline void f_绑定关联对象(void* data) { 
		m_刚体->userData = data;
		m_Shape->userData = data; 
	}

	//void f_setLocation(const vec3& loc);
	//void f_setRot(const vec3& loc);
	void f_setLocRot(const vec3& loc, const vec3& r);
	void f_setPos(const vec3& l);
	void f_setRot(const vec3& r);
	void f_setVel(const vec3& l);
	vec3 f_getLocation();

};







struct S_Px静态碰撞 : public S_物理体 {
	physx::PxRigidStatic*	m_刚体;
	physx::PxShape*			m_Shape;


	S_Px静态碰撞(S_Px物理引擎核心* core, S_物理几何体& geom, S_物理材质& 材质, uint32 key = 0);
	~S_Px静态碰撞();



	inline void* f_getBody() { return dynamic_cast<physx::PxRigidActor*>(m_刚体); }
	inline void* f_get关联对象() { return m_刚体->userData; }

	inline void f_绑定关联对象(void* data) {
		m_刚体->userData = data;
		m_Shape->userData = data;
	}

	//void f_setLocation(const vec3& loc);
	//void f_setRot(const vec3& loc);
	void f_setLocRot(const vec3& loc, const vec3& r);
	void f_setPos(const vec3& l);
	void f_setRot(const vec3& r);
	void f_setVel(const vec3& l);
	vec3 f_getLocation();

};

